home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume17 / manlist / part01 next >
Encoding:
Internet Message Format  |  1991-03-23  |  5.7 KB

  1. From: bud@mtek.com (Bud Hovell)
  2. Newsgroups: comp.sources.misc
  3. Subject: v17i063:  manlist - list available man pages, Part01/01
  4. Message-ID: <1991Mar22.155157.8691@sparky.IMD.Sterling.COM>
  5. Date: 22 Mar 91 15:51:57 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: b06b8a55 020366fd 4de0e583 6d03d5b0
  8.  
  9. Submitted-by: Bud Hovell <bud@mtek.com>
  10. Posting-number: Volume 17, Issue 63
  11. Archive-name: manlist/part01
  12.  
  13. This little script is something I've been using for a *long* time, and I
  14. thought I'd offer it as a possible addition to the archives, since it
  15. seems to fill a gap, on our SYSV machines.
  16.  
  17. Basically, it does a listing of all available 'man' pages, either by
  18. section, key word, or in-total. The header further qualifies how it works.
  19. No man page for it - it's pretty simple (my kind of work :-).
  20.  
  21. Bud Hovell
  22. ____________
  23. bud@mtek.com
  24.  
  25. --------------------- cut ------------------------ cut -------------------
  26. #! /bin/sh
  27. # This is a shell archive.  Remove anything before this line, then feed it
  28. # into a shell via "sh file" or similar.  To overwrite existing files,
  29. # type "sh file -c".
  30. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  31. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  32. # Contents:  manlist
  33. # Wrapped by kent@sparky on Fri Mar 22 09:23:11 1991
  34. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  35. echo If this archive is complete, you will see the following message:
  36. echo '          "shar: End of archive."'
  37. if test -f 'manlist' -a "${1}" != "-c" ; then 
  38.   echo shar: Will not clobber existing file \"'manlist'\"
  39. else
  40.   echo shar: Extracting \"'manlist'\" \(3623 characters\)
  41.   sed "s/^X//" >'manlist' <<'END_OF_FILE'
  42. X# $Id: manlist,v 3.4 91/03/21 16:00:52 bbh Usenet_Rel $
  43. X#
  44. X# Purpose: List 'man' pages on-line, either by key word, or by section, or in
  45. X#          total, and tell us of any not compressed.
  46. X#
  47. X# Usage:   manlist [ -list | [ section# ] [ keyword ] ]
  48. X#
  49. X# This script was written for use with man directories organized under
  50. X#          ~cat|man[1-8] nomenclature, and where man pages are stored 
  51. X#          in compressed format (we use Gil Kloepfer's 'man' program). It
  52. X#          has been installed only on 3b1 and 3b2 machines. If you don't
  53. X#          want uncompressed files so labelled, then just delete the line:
  54. X#
  55. X#                -e 's/[a-z,A-Y,0-9]$/&  \(not compressed\)/g' \
  56. X#
  57. X# Caveat:  This script will NOT work if any of your cat|man directory names
  58. X#          end in a letter rather than a number (~/manl, for example).
  59. X#
  60. X# Author:  Bud Hovell <bbh@mtek.com>
  61. X#
  62. X########################## edit these variables ###########################
  63. X# Number of display lines on your terminal?
  64. Xscreen=23
  65. X# Where the 'man' directory lives:
  66. Xmandir=/usr/man
  67. X# Your favorite pager:
  68. Xpager=/usr/local/bin/less
  69. X# How your machine knows who it is:
  70. Xhostname=`uuname -l`
  71. X############################### edit no more ##############################
  72. X# What's he looking for?
  73. Xcd $mandir
  74. Xcase $1 in
  75. X-list) # List section names and numbers:
  76. X       cat << "end_list"
  77. X
  78. X                          'MAN' SECTION LISTING
  79. X
  80. X       Section 1: USER COMMANDS
  81. X       Section 2: SYSTEM CALLS
  82. X       Section 3: SUBROUTINES
  83. X       Section 4: SPECIAL FILES
  84. X       Section 5: FILE FORMATS AND CONVENTIONS
  85. X       Section 6: GAMES
  86. X       Section 7: MACRO PACKAGES AND LANGUAGE CONVENTIONS
  87. X       Section 8: SYSTEM MAINTENANCE COMMANDS
  88. X
  89. Xend_list
  90. Xexit 0
  91. X;;
  92. X[1-8]) # Gave us a valid section number as first argument
  93. X       sec=$1
  94. X       case $sec in # Manual section definitions:
  95. X            1) section="(USER COMMANDS)"                 ;;
  96. X            2) section="(SYSTEM CALLS)"                 ;;
  97. X            3) section="(SUBROUTINES)"                     ;;
  98. X            4) section="(SPECIAL FILES)"                 ;;
  99. X            5) section="(FILE FORMATS AND CONVENTIONS)"         ;;
  100. X            6) section="(GAMES)"                     ;;
  101. X            7) section="(MACRO PACKAGES AND LANGUAGE CONVENTIONS)"     ;;
  102. X            8) section="(SYSTEM MAINTENANCE COMMANDS)"             ;;
  103. X       esac
  104. X       if test "$2"
  105. X       then alpha=$2
  106. X       fi
  107. X       break
  108. X;;
  109. X[0,9]|-*) # Error - invalid section number given
  110. X       echo "\nUsage: $0 [ -list | [ section# ] [ keyword ] ]\n"
  111. X       exit 0
  112. X;;
  113. X*)     # Ok - we'll treat any other first argument as a keyword
  114. X       alpha=$1
  115. X;;
  116. Xesac
  117. X
  118. X# What do we search on?
  119. Xif [ "$alpha" ]
  120. Xthen if [ $sec ]
  121. X     then check=./*${sec}/*${alpha}*
  122. X     else check=./*/*${alpha}*
  123. X     fi
  124. Xelif [ "$sec" ]
  125. X     then check=*${sec}/*
  126. X     else check=*
  127. Xfi
  128. X
  129. X# Send output to pager (list <= 1 screen)?
  130. Xhowmany=`ls -a $check | wc -l | sed 's/^[ ]*//p'`
  131. Xif test "$howmany" -lt $screen-4
  132. Xthen output="cat -u"
  133. Xelse output=$pager
  134. Xfi
  135. X
  136. X# Print the appropriate message:
  137. Xtput clear
  138. Xecho "\n\nListing 'man' pages \c"
  139. Xtest $sec   && echo "in section ${sec} ${section}\n\t\c"
  140. Xtest $alpha && echo "having root-name '${alpha}' \c"
  141. Xecho "on host '${hostname}'\n"
  142. X
  143. X# Go to press:
  144. Xls -a $check | sort -f  \
  145. X             | sed  -e '/^\.\.$/D' \
  146. X              -e '/^\.$/D' \
  147. X                -e '/^[cm]a[tn].*:$/D' \
  148. X            -e '/^[     ]*$/D' \
  149. X            -e 's/[a-z,A-Y,0-9]$/&  \(not compressed\)/g' \
  150. X                    -e 's/^.*[cm]a[tn][1-8].//g'  \
  151. X            -e 's/^.*\.[1-8].*/             &/g'  \
  152. X                    -e 's/\.Z$//g' \
  153. X            -e 's/^.* found.*$/No entry there./g' \
  154. X         | $output
  155. X
  156. X# someone want to make this fugly filter a bit more-elegant? :-)
  157. X
  158. END_OF_FILE
  159.   if test 3623 -ne `wc -c <'manlist'`; then
  160.     echo shar: \"'manlist'\" unpacked with wrong size!
  161.   fi
  162.   # end of 'manlist'
  163. fi
  164. echo shar: End of archive.
  165. exit 0
  166. exit 0 # Just in case...
  167. -- 
  168. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  169. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  170. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  171. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  172.